Texture InputTexture;
Texture Mask;

float4 color = {0.0,0.0,0.0,1.0};
float eps = 0.01;


sampler inputTexture = sampler_state 
{ 
    texture = <InputTexture>; 
    magfilter = LINEAR; 
    minfilter = LINEAR; 
    mipfilter = LINEAR; 
};

sampler mask = sampler_state 
{ 
    texture = <Mask>; 
    magfilter = LINEAR; 
    minfilter = LINEAR; 
    mipfilter = LINEAR; 
}; 
 
 
struct VS_OUTPUT
{
	float4 Position	: POSITION;
	float2 TexCoords : TEXCOORD0;
};

float4 Color_PS (VS_OUTPUT Input) : COLOR0
{
	float4 mask_color = tex2D(mask, Input.TexCoords);
	if((mask_color.r < eps) && (mask_color.g < eps) && (mask_color.b < eps))
		return color;
	else
	{
		float4 orig_color = tex2D(inputTexture, Input.TexCoords);
		return orig_color;
	}
}
 
technique Color
{
	pass P0
	{
		PixelShader = compile ps_3_0 Color_PS();
	}
}